home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 114 / gfagem.txt < prev    next >
Text File  |  1987-11-28  |  10KB  |  239 lines

  1. I have tested most of the routines here as completely as I could and 
  2. have found no bugs.  However, I make no guarantees to the programmer 
  3. that they are 100% error free.  Since I'm just poking things into 
  4. the GEM control arrays, chances are if there are any bugs it's due to 
  5. a typo and can be quite easily fixed.  Please contact me if you make 
  6. any changes or find bugs.  GEM is very powerful, and can be 
  7. dangerous as well.  Giving GEM a bad parameter can send your program 
  8. off into memory never never land, never to return.  With C, this 
  9. just causes the frustration of resetting and recompiling...with GFA 
  10. however, it is easy to go long stretches without saving, only to 
  11. watch it waste away in a second when you rub GEM the wrong way.  
  12. So...save your work often.  I hope you find these routines useful 
  13. and fun, as I think they take a lot of pain out of GEM programming.  
  14. If you're so inclined, you can send lots of money to:
  15. Paul Chinn
  16. 4995 Fern Place
  17. Rohnert Park Ca. 94928
  18. or lots of praise to Compuserve ID, 76157,55
  19. Direct complaints to Atari corp.
  20.  
  21.  
  22. GEM Bindings for GFA Basic. 1987 Paul Chinn
  23. Release 1
  24.  
  25.      As most people are well aware, GFA basic is perhaps the most 
  26. powerful basic ever created.  Not only that, but its performance 
  27. rivals that of many compiled languages such as C or Pascal.  
  28. Graphics, sound, I/O, GFA does everything...well maybe not 
  29. _everything_.  GFA's weakest part, in my opinion, is its use of GEM.  
  30. As implemented GFA is great for beginning GEM programmers.  What 
  31. could be easier than OPENW 1 to pop open a window?  Well, with the 
  32. simplicity you lose much of the power of GEM.  Under GFA
  33. only four windows can be opened, and GFA maintains tight control 
  34. over them, redirecting output to only the open window.  Use of 
  35. resource files is limited to just menus and these are limited to 
  36. text only.  As I mentioned, as is GFA's GEM is fine for beginners 
  37. but is probably missing close to 90% of GEM functions, functions 
  38. that are very desirable for advanced programming.  Fortunately, the 
  39. programmers of GFA left their product amazingly open ended with 
  40. hooks to all sorts of neat internal ST stuff...like GEM.        
  41.  
  42. I've taken advantage of these hooks, and created the set of 
  43. subroutines you have here.  Now, right at your fingertips are all 
  44. the GEM AES calls(except for appl_read,appl_write,and the play and 
  45. record functions which are rarely used).  I've adopted the 'C' 
  46. format for these calls, so GFA programmers can take advantage of the 
  47. numerous tutorials about GEM in C.  Also, I myself, am a C 
  48. programmer.  I have found GFA invaluable for testing out ideas and 
  49. program mock-ups and now with these utilities, a GEM program can be 
  50. translated virtually verbatim from basic to C(or vice versa). Not 
  51. only that, but I can test out the AES and GEM in real time, from 
  52. GFA's direct mode...something not previously possible.  The rest of 
  53. this doc file will explain the use of these routines.  It is not 
  54. intended as a tutorial on GEM but will outline each of the calls, 
  55. and give some explanations for overcoming some of the 
  56. dissimilarities between basic and C.
  57.  
  58. Using the routines:
  59.  
  60. To use the routines you have to include the following routines in 
  61. each program:
  62. fill_gcont()
  63. fill_gint()
  64. gem()
  65. crack_add()
  66. vs_clip()
  67. Gem(),fill_gcont(), and fill_gint() are used by the routines and you 
  68. need not worry about their use.  The other 2 will be explained 
  69. later.  All these routines are at the end of the listing.
  70.  
  71. The rest of the routines are the actual GEM calls and you may 
  72. include all of them in your program or only the ones you need.  I 
  73. suggest that when you use my routines you don't mix in the GFA 
  74. counterpart.  So if you use wind_open, keep away from GFA's openw.
  75.  
  76. The calls for the most part, follow their C counterparts exactly.
  77. So the following call in C:
  78. handle=wind_create(11,20,20,100,100);
  79. would look like:
  80. @wind_create(11,20,20,100,100)
  81. in GFA.  As you can see, the transition is an easy one.  There are a 
  82. few exceptions however.
  83.  
  84.  
  85. Crossing the C to BASIC bridge:
  86.  
  87. Once difference between Basic and C is that unlike C, basic cannot 
  88. return values from subroutines.  I solved this by creating the 
  89. global variable ret.  So after a call, ret will contain the value 
  90. normally returned by the C counterpart.  In the above example, ret 
  91. would equal handle.
  92.  
  93. Another difference concerns passing variables.  In C the following 
  94. is perfectly valid:
  95. rsrc_load("Dummy.rsc");
  96. In GFA, however, you will get an error because all my GEM routines 
  97. take integers as parameters and unlike C, GFA does not convert 
  98. types.(Note: in GFA integers are 4 bytes while in C they are only 
  99. 2...this will not usually be a problem).  The solution is again 
  100. simple:
  101. a$="DUMMY.RSC"
  102. @rsrc_load(varptr(a$))
  103. is the working basic equivalent.
  104.  
  105. Finally, if the C call is something like:
  106. do_it(&x,&y,j);
  107. the GFA call would be
  108. @do_it(*x,*y,j)
  109. The & in C and the * in basic tell the function to pass the 
  110. _address_ of the variable so that its value may be changed by the 
  111. function.  If this concept seems radically new to you, I suggest you 
  112. brush up on variables and pointers before continuing.
  113.  
  114. There are some other differences that affect individual functions 
  115. but they are minor and will be explained when needed.
  116.  
  117.  
  118. And now the routines:
  119. For explanation of the routines and their variables I suggest the 
  120. abacus GEM book or Tim Oren's excellent series of tutorials on 
  121. Compuserve.  The variable names shown here are the names used in the 
  122. actual routines and because of the way GFA handles local and global 
  123. variables you _MUST NOT_ use the same names for variables when 
  124. calling my routines.
  125.  
  126. vs_clip(cx%,cy%,ch%,cw%,toggle%)
  127. this call sets the clipping rectangle.  You specify the corner x and 
  128. y and the width and height.  Clipping is turned on when toggle% is 1 
  129. and off when toggle% is 0.  Turn off clipping only when you can be 
  130. sure you won't write over the wrong part of the screen. This command 
  131. must be used so that you don't draw over other windows or open ACCs.
  132.  
  133. *****AES initializing routines
  134. Sets up your application.(I believe GFA takes care of this so they 
  135. probably aren't needed)
  136.  
  137. @appl_init
  138. @graf_handle(*hwchar%,*hhchar%,*hwbox%,*hhbox%)
  139.  
  140. *****AES window management
  141.  
  142. @wind_get(ghandle%,gfield%,*gw1%,*gw2%,*gw3%,*gw4%)
  143. @wind_create(crkind%,crwx%,crwy%,crww%,crwh%)
  144. @wind_open(ohandle%,owx%,owy%,oww%,owh%)
  145. @wind_close(clhandle%)
  146. @wind_delete(dhandle%)
  147. @wind_set(shandle%,sfield%,sw1%,sw2%,sw3%,sw4%)
  148. ****>now's a good time to introduce the routine crack_add().  If you 
  149. use wind_set to set the address of the text in the name or info 
  150. lines of a window, you need to pass the lo and hi words in sw1% and 
  151. sw2%.  This is how you do it:
  152.      title$="My Window Title"
  153.      title_add=varptr(title$)
  154.      @crack_add(title_add)'crack_add returns 2 global variables: 
  155.           hi% & lo%
  156.      @wind_set(shandle%,2,lo%,hi%,0,0)
  157.  
  158. @wind_find(fmx%,fmy%)
  159. @wind_update(ubegend%)
  160. @wind_calc(ctype%,ckind%,cinx%,ciny%,cinw%,cinh%,*coutx%,*couty%,
  161.            *coutw%,*couth%)
  162.  
  163. *****AES event handlers
  164.  
  165. @evnt_keybd
  166. @evnt_button(bclicks%,bmask%,bstate%,*bmx%,*bmy%,*bbutton%,*bkstate%)
  167. @evnt_mouse(moflags%,mox%,moy%,mowidth%,moheight%,*momx%,*momy,
  168.             *mobutton%,*mokstate)
  169. @evnt_timer(tlocount%,thicount%)
  170. @evnt_mesag(mgpbuff%)
  171. *****>buffer% has to be the address of a 16 byte buffer here's a how 
  172. I like to do it:
  173.      buffer$="0123456789abcdef"
  174.      buffer%=varptr(buffer$)
  175.      @evnt_mesag(buffer%)
  176. Then you can read the buffer like this:
  177.      val1%=dpeek(buffer%+offset)'offset must be a multiple of 2
  178. @evnt_multi(mflags%,mbclicks%,mbmask%,mbstate%,mm1flags%,mm1x%,
  179.             mm1y%,mm1width%,mm1height%,mm2flags%,mm2x%,mm2y%,
  180.             mm2width%,mm2height%,mmgpbuff%,mtlocount%,mthicount%,
  181.             *mmox%,*mmoy%,*mmobutton%,*mmokstate%,*mkreturn,
  182.             *mbreturn%)'what a beast!!!!
  183.  
  184. *****File Selection Manager
  185.  
  186. @fsel_input(iinpath%,iinsel%,*iexbutton%)
  187.  
  188.  
  189. ****AES Object manager
  190.  
  191. @objc_draw(dtree%,drstartob%,drdepth%,drxclip%,dryclip%,drwclip%,
  192.            drhclip%)
  193. @objc_find(ftree%,fstartob%,fdepth%,fmx%,fmy%)
  194. @objc_offset(oftree%,ofobject%,*ofxoff%,*ofyoff%)
  195. @objc_edit(edtree%,edobject%,edchar%,edidx%,edkind%,*ednewidx%)
  196. @objc_change(ctree%,cobject%,cresvd%,cxclip%,cyclip%,cwclip%,
  197.              chclip%,cnewstate%,credraw%)
  198.  
  199. *****Dialog box manager
  200.  
  201. @rsrc_load(lpfname%)
  202. @rsrc_free
  203. @rsrc_gaddr(gtype%,gindex%,*gaddr%)
  204. @rsrc_saddr(stype%,sindex%,saddr%)
  205. @form_do(do_tree%,dostartob%)
  206. @form_dial(diflag%,dilittx%,dilitty%,dilittw%,dilitth%,dix%,diy%,
  207.            diw%,dih%)
  208. @form_center(ctree%,*cx%,*cy%,*cw%,*ch%)
  209. @form_alert(adefbttn%,astring%)
  210. @form_error(enum%)
  211.  
  212.  
  213. *****AES drop down menu manager
  214.  
  215. @menu_bar(btree%,bshow%)
  216. @menu_icheck(ctree%,citem%,ccheck%)
  217. @menu_enable(etree%,eitem%,eenable%)
  218. @menu_tnormal(ntree%,ntittle%,nnormal%)
  219. @menu_text(ttree%,titem%,ttext%)
  220. @menu_register(rapid%,rpstring%)
  221.  
  222.  
  223. *****AES graphic library
  224.  
  225. @graf_rubberbox(rx%,ry%,rminwidth%,rminheight%,*rlastwidth%,
  226.                 *rlastheight%)
  227. @graf_dragbox(dwidth%,dheight%,dstartx%,dstarty%,dboundx%,dboundy%,
  228.               dboundw%,dboundh%,*dfinishx%,*dfinishy%)
  229. @grav_movebox(mwidth%,mheight%,msourcex%,msourcey%,mdestx%,mdesty%)
  230. @graf_growbox(gstx%,gsty%,gstwidth%,gstheight%,gfinx%,ginfy%,
  231.               gfinwidth%,gfinheight%)
  232. @graf_shrinkbox(sfinx%,sfiny%,sfinwidth%,sfinheight%,sstx%,ssty%,
  233.                 sstwidth%,sstheight%)
  234. @graf_watchbox(wptree%,wobject%,winstate%,woutstate%)
  235. @graf_slidebox(slptree%,slparent%,slobject%,slvh%)
  236. @graf_mouse(monumber%,mofaddr%)
  237. @graf_mkstate(*mkmx%,*mkmy%,*mkmstate%,*mkkstate%)
  238.  
  239.